package com.yanqu.road.entity.activity.washe.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.enums.washe.eWasheFunction;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_n_washepvp_box")
public class WasheBoxConfig {

    @FieldTypeAnnotation(desc = "活动ID", select = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "宝箱图标")
    private int boxId;
    @FieldTypeAnnotation(desc = "赛季")
    private int seasonId;
    @FieldTypeAnnotation(desc = "品质")
    private int quality;
    @FieldTypeAnnotation(desc = "条件，荣誉点数量")
    private String param;
    @FieldTypeAnnotation(desc = "新版奖励")
    private String newrewards;

    // 缓存
    private List<Long> scoreLimit;

    // 旧版
    @FieldTypeAnnotation(desc = "奖励")
    private String rewards;
    private List<Integer> weightList;
    private List<String> rewardList;

    // ========================================

    public void init(int version) {

        List<Integer> weightList = new ArrayList<>();
        List<String> rewardList = new ArrayList<>();
        if (!eWasheFunction.NewBoxConfig.isOpen(version)) {
            List<String> weightRewardList = StringUtils.stringToStringList(rewards, "\\|");
            for (String weightRewardStr : weightRewardList) {
                List<String> weightReward = StringUtils.stringToStringList(weightRewardStr, "#");
                rewardList.add(weightReward.get(0));
                weightList.add(Integer.valueOf(weightReward.get(1)));
            }
        }
        this.weightList = weightList;
        this.rewardList = rewardList;

        this.scoreLimit = StringUtils.stringToLongList(param, "\\|");
    }

    // ========================================

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getSeasonId() {
        return seasonId;
    }

    public void setSeasonId(int seasonId) {
        this.seasonId = seasonId;
    }

    public List<Integer> getWeightList() {
        return weightList;
    }

    public void setWeightList(List<Integer> weightList) {
        this.weightList = weightList;
    }

    public List<String> getRewardList() {
        return rewardList;
    }

    public void setRewardList(List<String> rewardList) {
        this.rewardList = rewardList;
    }

    public int getBoxId() {
        return boxId;
    }

    public void setBoxId(int boxId) {
        this.boxId = boxId;
    }

    public int getQuality() {
        return quality;
    }

    public void setQuality(int quality) {
        this.quality = quality;
    }

    public String getRewards() {
        return rewards;
    }

    public void setRewards(String rewards) {
        this.rewards = rewards;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public List<Long> getScoreLimit() {
        return scoreLimit;
    }

    public void setScoreLimit(List<Long> scoreLimit) {
        this.scoreLimit = scoreLimit;
    }

    public String getNewrewards() {
        return newrewards;
    }

    public void setNewrewards(String newrewards) {
        if (newrewards != null && !"0".equals(newrewards)) {
            this.newrewards = newrewards;
        }
    }
}
